﻿using BCVP.Net8.Model.Models;
using BCVP.Net8.Repository.Base;
using BCVP.Net8.Repository.UnitOfWorks;

using SqlSugar;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BCVP.Net8.Repository
{
    public class BookRepository : BaseRepository<Book>, IBookRepository
    {
        public BookRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
        {
            Db.CodeFirst.InitTables(typeof(Book));
        }

        //private readonly ISqlSugarClient _dbBase;
        //public BookRepository(ISqlSugarClient sqlSugarClient) : base(sqlSugarClient)
        //{
        //    _dbBase = sqlSugarClient;
        //    Db.CodeFirst.InitTables(typeof(Book));
        //}

        public async Task<Book> QueryByName(string name)
        {
            return await Db.Queryable<Book>().Where(x => x.BookName == name).FirstAsync();
        }
    }
}
